#pragma once
#include <QHash>
#include <QString>

enum LOG_LEVEL
{
    LOG_LEVEL_INFO,
    LOG_LEVEL_DEBUG,
    LOG_LEVEL_WARNING,
    LOG_LEVEL_CRITICAL,
    LOG_LEVEL_FATAL
};

const static QHash<LOG_LEVEL, QString> CSHASH_LOG_LEVEL_STR =
{
    {LOG_LEVEL_INFO, QString("INFO")},
    {LOG_LEVEL_DEBUG, QString("DEBUG")},
    {LOG_LEVEL_WARNING, QString("WARNING")},
    {LOG_LEVEL_CRITICAL, QString("CRITICAL")},
    {LOG_LEVEL_FATAL, QString("FATAL")}
};

class LogWriter
{
    friend void writeLog(const QString&, LOG_LEVEL);

private:
    static LogWriter* getInstance();
    LogWriter() = default;
    ~LogWriter() = default;

    void writeLog(const QString& word, LOG_LEVEL logLevel=LOG_LEVEL_DEBUG);
    void writeToFile(const QString& word, const QString& strDir, const QString& filename);
    void writeToConsole(const QString& word);
};

inline void writeLog(const QString& word, LOG_LEVEL logLevel=LOG_LEVEL_DEBUG)
{
    LogWriter::getInstance()->writeLog(word, logLevel);
}
